Generally, when a plurality of agents are administered to a patient in medical facilities such as hospitals, the agents taken at a time are packed together with a packing material and given to a patient so that the patient may not take wrong types of agents or the wrong number of agents by mistake. In correct dosage or combination of agents can cause serious adverse effects. For this reason, sorting and packing operations of agents are required to be manually made. However, such manual sorting and packing operations can cause errors. Thus, there have been conventionally provided inspective devices for granular materials for inspecting the types and quantity of packed agents (refer to, for example, Japanese Published Examined Application Publication No. 4-17665).
In an inspective device for granular material disclosed in Japanese Published Examined Application Publication No. 4-17665, an image of an agent is picked up by an imaging means such as a CCD camera and the image is subjected to data processing such as binarization to obtain image data. Then, the data is processed to find area, circumference and complexity of each object in the image. Based on the area and the complexity, it is determined whether or not the object in the image is an agent and the number of agents is acquired. Complexity means a value obtained by dividing a square of circumference by area.